cmake_minimum_required(VERSION 3.5)
project(vio)

#set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS}  -w  -O0 -march=native -g -std=c++11")
#set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -w   -O0 -march=native -g -std=c++11")
# 定义可接收的参数
set(UBUNTU_VERSION "" CACHE STRING "Ubuntu version")
set(UBUNTU_CODENAME "" CACHE STRING "Ubuntu codename")

message(STATUS "Building for Ubuntu ${UBUNTU_VERSION} (${UBUNTU_CODENAME})")

set(CMAKE_CXX_STANDARD 14)  
set(CMAKE_CXX_STANDARD_REQUIRED ON)

set(CMAKE_BUILD_TYPE "Release")

find_package(Ceres REQUIRED)

find_package(Eigen3 REQUIRED)
include_directories(/usr/include/eigen3
		    /usr/include)

include_directories(
    modules/
)

include_directories(${CERES_INCLUDE_DIRS})

add_library(${PROJECT_NAME} 
    modules/mapping/sliding_window.cc

    modules/common/so2.cc
    modules/common/se2.cc

    modules/preintegration/imu_preintegration.cc
    modules/preintegration/wheel_preintegration.cc

    modules/feature/feature.cc
    modules/feature/feature_matcher.cc
	modules/feature/feature_database.cc
	modules/feature/extractor.cc

	modules/frame/frame.cc

	modules/triangulator/triangulate.cc
	modules/optimizer/triangulate_factor.cc
	modules/optimizer/sliding_window_optimizer.cc
	modules/optimizer/imu_factor.cc
	modules/optimizer/wheel_factor.cc
	modules/optimizer/marginalization_factor.cc

	modules/sensor/sensor_sync.cc
	
    modules/publisher/publisher.cc
)

find_package(OpenCV REQUIRED)

target_link_libraries(${PROJECT_NAME} ${OpenCV_LIBS} ${CERES_LIBRARIES})

include_directories(
    apps/
)

find_package(Pangolin REQUIRED)
add_library(pangolin_viewer
            STATIC
            apps/pangolin_viewer/viewer.h
            apps/pangolin_viewer/color_scheme.h
            apps/pangolin_viewer/viewer.cc
            apps/pangolin_viewer/color_scheme.cc)

target_include_directories(pangolin_viewer 
                           PUBLIC
                           ${Pangolin_INCLUDE_DIR})
                           
target_link_libraries(pangolin_viewer
                      PUBLIC
                      ${PROJECT_NAME}
					  ${Pangolin_LIBRARIES}
)

add_executable(main_kaist apps/main_kaist.cc apps/read_kaist_data.cc apps/undistortion.cc)
target_link_libraries(main_kaist pangolin_viewer)
